<template>
  <div id="recommend" @click="topText">
    
    <div class="recommend-nav" v-for="t in choseArr" :key="t.objectId" @click="morePage(t.objectId)">
    <router-link :to="id" tag="div" >
      <p class="recommend-nav-title">{{ t.title }}</p>
      <div class="recommend-nav-body">
        <div class="text">{{ t.body }}</div>
        <img :src="t.topImage.url" />
      </div>
    <div class="all-text">全文<span></span></div>
   
    </router-link>
    </div>

  </div>
</template>

<script>

export default {
  props: {
    choseArr: Array,
    id:String
  },
  data() {
    return {
      path: 'articles/' + this.id
    };
  },
  methods: {
    morePage(objectId) {
       this.$emit("changeId", objectId);
    },
    topText() {
      document.documentElement.scrollTop = 0;
    }
  },
};
</script>

<style lang="scss" scoped>
#recommend {
  margin: 2vh 0;
  width: 100vw;

  .recommend-nav {
    margin: 0 auto 2vh;
    width: 90vw;
    height: 150px;
    background-color: rgba(199, 192, 192, 0.29);
    border-radius: 20px;
  overflow: hidden;
  box-shadow: 0px 10px 15px #888888;

    .recommend-nav-title {
      display: block;
      margin: 0 auto;
      padding-bottom: 20px;
      padding-top: 20px;
      width: 90%;
      height: 18px;
      font-size: 18px;
      font-weight: 700;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .recommend-nav-body {
      display: flex;
      margin: 10px auto;
      width: 90%;
      height: 48px;

      .text {
        width: 70%;
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
      }

      img {
        width: 30%;
        height: 100%;
      }
    }

    .all-text {
      margin: 0 auto;
      width: 90%;
      text-align: right;
      font-size: 14px;

      span {
        display: inline-block;
        border: 10px solid #3EAD3E;
        border-top: 6px transparent solid;
        border-bottom:6px transparent solid;
        border-right:none;
      }
    }
  }
}
</style>